package com.ktjy.ktmall.dao.impl;

import com.ktjy.ktmall.dao.BannerItemDao;
import com.ktjy.ktmall.dao.BaseDao;
import com.ktjy.ktmall.entity.BannerItem;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @auth wzy
 * @date 2024/10/12 9:39
 */
public class BannerItemDaoImpl extends BaseDao implements BannerItemDao {
    @Override
    public List<BannerItem> findByType(int type) {
        List<BannerItem> list = new ArrayList<>();
        String sql = "select * from t_banner where `enabled` = 0 and `type` = ?";
        rs = super.executeQuery(sql, type);
        try {
            while (rs.next()) {
                BannerItem b = new BannerItem(rs.getInt(1), rs.getString(2),
                        rs.getString(3), rs.getInt(4), rs.getInt(5),
                        rs.getString(6), rs.getString(7));
                list.add(b);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            super.closeAll(rs, pstmt, conn);
        }
        return list;
    }

    @Override
    public BannerItem findById(int id) {
        return null;
    }
}
